$(document).ready(function(){
	var startpage=0;
	getData();

	$.post("manager/getlogin",
	        function(data){
	        
	        console.log(data); 
	        var loginname=data.name;
	       console.log(loginname); 
	       $("#helloname").text(loginname);
	       
	        }, "json");
	
	var fruits = new Array();
	
	
	
	//复选框的点击事件
	function GetIds() {

		//获取所有的复选框
		$.each($("input:checkbox[name='choosebox']"),function () {
		var v = this.id;
		
		//被选中的复选框
			if (this.checked) {
		
				if (fruits.toString() == "") {
					
				//往数组里面添加值
					fruits.push(v);
					console.log("GetIds()-------2--------"+v);
				}else {//判断id数组中是否含有你以前存入的元素，没有则添加
					if ($.inArray(v, fruits) < 0) {
						console.log("GetIds()-------1--------"+v);
						fruits.push(v);
					}
				}
			}else {//未被被选中的复选框
				
				if ($.inArray(v, fruits) >=0) {
					fruits.splice($.inArray(v, fruits), v.length);
					
				}
			}
		});
	}
	
	//用数组来让你以前勾选的复选框恢复以前的状态
	function Fan() {
		for(var i=0;i<fruits.length;i++){
			var f=fruits[i];
			
			$.each($("input:checkbox[name='choosebox']"),function (){
				var v = this.id;
					if (v==f) {
						/*this.checked = true;*/
						$("#"+v).prop('checked', true);
						console.log("Fan()------1---------"+v);
					}
				});
		}
	
	}
	
	 $("#excelbtn").click(function(){
		 GetIds();
			var strify = JSON.stringify(fruits);//将数组转化为json字符串
			console.log(strify);

			 $.ajax({
		            type:"post",
		            async:false,
		            data:{idliet2:fruits},
		            url:"po/Excelpolist",
		            success: function (res) {
		                if(res!=null){
		                	window.location.href="po/Excelpolist2";
		                }
		                
		               
		            },
		            error: function () {
		                alert("失败");
		           
		            }
		        });
			
				   
				
		});
			
	 //分页查询
	 function getData(){
		 $("#chooseth").show();
		 GetIds();
		 $.getJSON("entry/showAllPolist",{start:startpage},function(json){
			 console.log(json);
			 var contentdata=json.content;
			 $("#tbodyprobtn").empty();
			 for(var i=0;i<contentdata.length;i++){
				//--时间转换  开始--//
				 function p(s){
					 if(s<10){
						  s='0'+s;
					  }else{
						  s=s
					  }
					 return s;
				 }
				  
				 var d=new Date(contentdata[i][3]);
				 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
				 //--时间转换  结束--//
						 $("#tbodyprobtn").append(
								 "<tr>"
								 +"<td>"+contentdata[i][0]
								 +"</td>"
								 +"<td>"+contentdata[i][1]
								 +"</td>"
								 +"<td>"+contentdata[i][2]
								 +"</td>"
								 +"<td>"+contentdata[i][4]
								 +"</td>"
								 +"<td>"+datetime
								 +"</td>"
								 +"<td>"+contentdata[i][7]
								 +"</td>"
								 +"<td name='tdid' id='tdid"+contentdata[i][0]+"'><span id='statucolor'>"+contentdata[i][6]
								 +"</span></td>"
								 +"<td><button style='display:none' type='button' class='btn btn-outline-info btn-sm' data-toggle='modal' data-target='#myModal2' id='btn1"+contentdata[i][0]+"' name='btn001' >退货</button>"
								 +"<input type='hidden' class='form-control' id='input"+contentdata[i][0]+"' name='inputname'/>"
								 +"<input type='hidden' class='form-control' id='ainput' name='ainputname'/>"
								 +"<input type='hidden' class='form-control' id='tdid2"+contentdata[i][0]+"'/>"
								 +"</td>"
								 +"<td id='choosetd"+contentdata[i][0]+"' name='choosetd'>"
								 +"<li class='list-group-item border-0' data-role='task'>"
								 +"<div class='d-flex w-100 justify-content-between align-items-center'>"
								 +"<div class='custom-control custom-checkbox material-checkbox'>"
								 +"<input type='checkbox' class='custom-control-input' id='followUp"+contentdata[i][0]+"' name='choosebox'>"
								 +"<label class='custom-control-label' for='followUp"+contentdata[i][0]+"'>☚</label>"
								 +"</div>"
								 +" </div>"
								 +"</li>"
								 +"</td>"
								
								 +"</tr>"
						 )
						 Fan();
						
						 $("#input"+contentdata[i][0]).val(contentdata[i][6]);
					
						
						 if(contentdata[i][6]=="未入库"){
							 $('#statucolor').replaceWith("<span style='color:red'>"+contentdata[i][6]+
							 "</span>");
							
						 }else if(contentdata[i][6]=="全部退货"){
							 $("#statucolor").replaceWith("<a id='typestyle"+contentdata[i][0]+"' name='a001' href='#' style='text-decoration:underline;color:blue'  data-toggle='modal' data-target='#myModal3'>"+contentdata[i][6]+
							 "</a>");
						 }else if(contentdata[i][6]=="部分退货"){
							 $("#statucolor").replaceWith("<a id='a2typestyle"+contentdata[i][0]+"' name='a002' href='#' style='text-decoration:underline;color:blue'  data-toggle='modal' data-target='#myModal3'>"+contentdata[i][6]+
							 "</a>");
						 }else{
							 $('#statucolor').replaceWith("<span>"+contentdata[i][6]+
							 "</span>");
						 }
						
			 }
			
			 $("a[name=a001]").click(function(){
					var id=this.id;
					var showid=id.slice(9);
					console.log(showid);
					$.getJSON("entry/findPoreturnsbyPoid",{findpoid:showid},function(json){
						console.log(json);
						$("#tbodyprobtn3").empty();
						for(var j=0;j<json.length;j++){
							 function p(s){
								 if(s<10){
									  s='0'+s;
								  }else{
									  s=s
								  }
								 return s;
							 }
							  
							 var d=new Date(json[j][3]);
							 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
							$("#tbodyprobtn3").append(
									 "<tr>"
									 +"</td>"
									 +"<td>"+json[j][0]
									 +"</td>"
									 +"<td>"+datetime
									 +"</td>"
									 +"<td>"+json[j][4]
									 +"</td>"
									 +"<td>"+json[j][2]
									 +"</td>"
									 +"</tr>"
							);
						}
						
					});
				});
			 $("a[name=a002]").click(function(){
				 var id2=this.id;
				 var showid2=id2.slice(11);
				 console.log(showid2);
				 $.getJSON("entry/findPoreturnsbyPoid",{findpoid:showid2},function(json){
					 console.log(json);
					 $("#tbodyprobtn3").empty();
					 for(var j=0;j<json.length;j++){
						 function p(s){
							 if(s<10){
								 s='0'+s;
							 }else{
								 s=s
							 }
							 return s;
						 }
						 
						 var d=new Date(json[j][3]);
						 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
						 $("#tbodyprobtn3").append(
								 "<tr>"
								 +"</td>"
								 +"<td>"+json[j][0]
								 +"</td>"
								 +"<td>"+datetime
								 +"</td>"
								 +"<td>"+json[j][4]
								 +"</td>"
								 +"<td>"+json[j][2]
								 +"</td>"
								 +"</tr>"
						 );
					 }
					 
				 });
			 });
			 $("td[name=tdid]").show(function(){
				var id=this.id;
				var numb=id.slice(4);
				//console.log(numb);
				var status=$("#input"+numb).val();
				//console.log(status);
				if(status=="未入库"){
					 $("#btn1"+numb).show();
				 }else{
					 $("#btn1"+numb).hide();
				 }
			 });
			 $("button[name=btn001]").click(function(){
				console.log("***************btn001***1******");
				 var id=this.id;
				 var numb=id.slice(4);
				 $("#poid").val(numb);
				 console.log("-----"+$("#poid").val());
			 });
			 $("#thnumid").unbind('blur').blur(function(){
				 var numb=$("#poid").val();
				 var cgnum=$("#tdid2"+numb).val();
				 console.log(cgnum);
				if($("#thnumid").val()>cgnum) {
					$("#thnump").show();
					$("#thnumid").focus();
				}else{
					$("#thnump").hide();
				}
			 });
			$("#btnReturns").unbind('click').click(function(){
				console.log("***************btnReturns***1******");
				console.log("***************btnReturns***2******"+$("#poid").val());
				if($("#comment").val()==""){
					$("#commentp").show();
					$("#comment").focus();
				}else{
					$("#commentp").hide();
					
					
					$.getJSON("entry/savePoreturns",{poid:$("#poid").val(),comment:$("#comment").val(),thnumid:$("#thnumid").val()},function(json){
						console.log(json);
						if(json.PolistTH!=null && json.PoreturnsTH!=null){
							alert("退货成功");
							window.location.href="hk_warecg1.html";
						}else{
							alert("退货失败");
						}
					});
				}
			
			});
			
			$("#excelbtn").click(function(){
				$("#chooseth").show();
				$("td[name='choosetd']").show();
			});
			//---分页开始---//
				 var totalpagenumber=json.totalPages;
				 $(".pagination").empty();
				 $(".pagination").append('<li class=""><a class="page-link" href="#" id="firstpage">首页</a></li>');
				 $(".pagination").append('<li class=""><a class="page-link" href="#" id="updata">上一页</a></li>');
				 for(var j=0;j<totalpagenumber;j++){
					 $(".pagination").append('<li class="page-item" id="pageno'+j+'"><a class="page-link" href="#">'+(j+1)+'</a></li>');
				 }
				
				 $(".pagination").append('<li class=""><a class="page-link" href="#" id="nextdate">下一页</a></li>');
				 //首页
				 $("#firstpage").click(function(){
					 startpage=0;
					 getData();
					
					
				 });
				 //上一页
				 $("#updata").click(function(event){
					 if(json.first){
						 event.preventDefault();
					 }else{
						 var intnum=new Number(startpage);
						 startpage=startpage-1;
						 getData();
						
					 }
				 });
				 //下一页
				 $("#nextdate").click(function(event){
					 if(json.last){
						 event.preventDefault();
					 }else{
						 var intnum=new Number(startpage);
						 startpage=startpage+1;
						 getData();
						
					 }
				 });
				 //当前页面
				 $(".page-item").click(function(){
					 var id=this.id;
					var intnum=id.substr(6);
					startpage=intnum;
					getData();
					
				 });
				 $(".page-item").removeClass("active");
				 $("#pageno"+startpage).addClass("active");
			 //--分页结束--//
		 });
	 }
	 //--查询开始--//
			 $("#select7day").click(function(){
				 var startpage2=0;
				 getDataby7day();
				 $("#chooseth").hide();
				 function getDataby7day(){

				 $.getJSON("entry/showPolistBy7Day",{start:startpage2},function(json){
					 console.log(json);
					 var contentdata=json.content;
					 $("#tbodyprobtn").empty();
					 for(var i=0;i<contentdata.length;i++){
							 function p(s){
								 if(s<10){
									  s='0'+s;
								  }else{
									  s=s
								  }
								 return s;
							 }
							  
							 var d=new Date(contentdata[i][3]);
							 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
									 $("#tbodyprobtn").append(
											 "<tr>"
											 +"<td>"+contentdata[i][0]
											 +"</td>"
											 +"<td>"+contentdata[i][1]
											 +"</td>"
											 +"<td>"+contentdata[i][2]
											 +"</td>"
											 +"<td>"+contentdata[i][4]
											 +"</td>"
											 +"<td>"+datetime
											 +"</td>"
											 +"<td>"+contentdata[i][7]
											 +"</td>"
											 +"<td name='tdid2' id='tdid2"+contentdata[i][0]+"'><span id='statucolor2'>"+contentdata[i][6]
											 +"</span></td>"
											 +"<td><button  type='button' class='btn btn-outline-info btn-sm' data-toggle='modal' data-target='#myModal2'id='btn12"+contentdata[i][0]+"' name='btn0012' >退货</button>"
											 +"<input type='hidden' class='form-control' id='input2"+contentdata[i][0]+"' name='inputname2'/>"
											 +"</td>"
											 +"</tr>"
									 ) 
									
									  $("#input2"+contentdata[i][0]).val(contentdata[i][6]);
									 if(contentdata[i][6]=="未入库"){
										 $('#statucolor2').replaceWith("<span style='color:red'>"+contentdata[i][6]+
										 "</span>");
										
									 }else if(contentdata[i][6]=="全部退货"){
										 $("#statucolor2").replaceWith("<a id='typestyle1"+contentdata[i][0]+"' name='a0011' href='#' style='text-decoration:underline;color:blue'  data-toggle='modal' data-target='#myModal3'>"+contentdata[i][6]+
										 "</a>");
									 }else if(contentdata[i][6]=="部分退货"){
										 $("#statucolor2").replaceWith("<a id='a2typestyle1"+contentdata[i][0]+"' name='a0012' href='#' style='text-decoration:underline;color:blue'  data-toggle='modal' data-target='#myModal3'>"+contentdata[i][6]+
										 "</a>");
									 }else{
										 $('#statucolor2').replaceWith("<span>"+contentdata[i][6]+
										 "</span>");
									 }
									
						 }
						 $("a[name=a0011]").click(function(){
								var id=this.id;
								var showid=id.slice(10);
								console.log(showid);
								$.getJSON("entry/findPoreturnsbyPoid",{findpoid:showid},function(json){
									console.log(json);
									$("#tbodyprobtn3").empty();
									for(var j=0;j<json.length;j++){
										 function p(s){
											 if(s<10){
												  s='0'+s;
											  }else{
												  s=s
											  }
											 return s;
										 }
										  
										 var d=new Date(json[j][3]);
										 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
										$("#tbodyprobtn3").append(
												 "<tr>"
												 +"</td>"
												 +"<td>"+json[j][0]
												 +"</td>"
												 +"<td>"+datetime
												 +"</td>"
												 +"<td>"+json[j][4]
												 +"</td>"
												 +"<td>"+json[j][2]
												 +"</td>"
												 +"</tr>"
										);
									}
									
								});
							});
						 $("a[name=a0012]").click(function(){
							 var id2=this.id;
							 var showid2=id2.slice(12);
							 console.log(showid2);
							 $.getJSON("entry/findPoreturnsbyPoid",{findpoid:showid2},function(json){
								 console.log(json);
								 $("#tbodyprobtn3").empty();
								 for(var j=0;j<json.length;j++){
									 function p(s){
										 if(s<10){
											 s='0'+s;
										 }else{
											 s=s
										 }
										 return s;
									 }
									 
									 var d=new Date(json[j][3]);
									 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
									 $("#tbodyprobtn3").append(
											 "<tr>"
											 +"</td>"
											 +"<td>"+json[j][0]
											 +"</td>"
											 +"<td>"+datetime
											 +"</td>"
											 +"<td>"+json[j][4]
											 +"</td>"
											 +"<td>"+json[j][2]
											 +"</td>"
											 +"</tr>"
									 );
								 }
								 
							 });
						 });
					 $("td[name=tdid2]").show(function(){
							var id=this.id;
							var numb=id.slice(5);
							console.log(numb);
							var status=$("#input2"+numb).val();
							console.log(status);
							if(status=="未入库"){
								 $("#btn12"+numb).show();
							 }else{
								 $("#btn12"+numb).hide();
							 }
						 });
					 $("button[name=btn0012]").click(function(){
						 var id=this.id;
						 var numb=id.slice(5);
						 $("#poid").val(numb);
					 });
					 //---分页开始---//
						 var totalpagenumber=json.totalPages;
						 $(".pagination").empty();
						 $(".pagination").append('<li class=""><a class="page-link" href="#" id="firstpage2">首页</a></li>');
						 $(".pagination").append('<li class=""><a class="page-link" href="#" id="updata2">上一页</a></li>');
						 for(var j=0;j<totalpagenumber;j++){
							 $(".pagination").append('<li class="page-item" id="pageno'+j+'"><a class="page-link" href="#">'+(j+1)+'</a></li>');
						 }
						
						 $(".pagination").append('<li class=""><a class="page-link" href="#" id="nextdate2">下一页</a></li>');
						 //首页
						 $("#firstpage2").click(function(){
							 startpage2=0;
							 getDataby7day();
						 });
						 //上一页
						 $("#updata2").click(function(event){
							 if(json.first){
								 event.preventDefault();
							 }else{
								 var intnum=new Number(startpage2);
								 startpage2=startpage2-1;
								 getDataby7day();
							 }
						 });
						 //下一页
						 $("#nextdate2").click(function(event){
							 if(json.last){
								 event.preventDefault();
							 }else{
								 var intnum=new Number(startpage2);
								 startpage2=startpage2+1;
								 getDataby7day();
							 }
						 });
						 //当前页面
						 $(".page-item").click(function(){
							 var id=this.id;
							var intnum=id.substr(6);
							startpage2=intnum;
							getDataby7day();
						 });
						 $(".page-item").removeClass("active");
						 $("#pageno"+startpage2).addClass("active");
					 //--分页结束--//
				 	});
				 }
			 });
			 
			 $("#select30day").click(function(){
				 var startpage3=0;
				 getDataby30day();
				 $("#chooseth").hide();
				 function getDataby30day(){

				 $.getJSON("entry/showPolistBy30Day",{start:startpage3},function(json){
					 console.log(json);
					 var contentdata=json.content;
					 $("#tbodyprobtn").empty();
					 for(var i=0;i<contentdata.length;i++){
						 function p(s){
							 if(s<10){
								  s='0'+s;
							  }else{
								  s=s
							  }
							 return s;
						 }
						  
						 var d=new Date(contentdata[i][3]);
						 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
								 $("#tbodyprobtn").append(
										 "<tr>"
										 +"<td>"+contentdata[i][0]
										 +"</td>"
										 +"<td>"+contentdata[i][1]
										 +"</td>"
										 +"<td>"+contentdata[i][2]
										 +"</td>"
										 +"<td>"+contentdata[i][4]
										 +"</td>"
										 +"<td>"+datetime
										 +"</td>"
										 +"<td>"+contentdata[i][7]
										 +"</td>"
										 +"<td name='tdid3' id='tdid3"+contentdata[i][0]+"'><span id='statucolor3'>"+contentdata[i][6]
										 +"</span></td>"
										 +"<td><button  type='button' class='btn btn-outline-info btn-sm' data-toggle='modal' data-target='#myModal2'id='btn13"+contentdata[i][0]+"' name='btn0013' >退货</button>"
										 +"<input type='hidden' class='form-control' id='input3"+contentdata[i][0]+"' name='inputname3'/>"
										 +"</td>"
										 +"</tr>"
								 ) 
								 $("#input3"+contentdata[i][0]).val(contentdata[i][6]);
								 if(contentdata[i][6]=="未入库"){
									 $('#statucolor3').replaceWith("<span style='color:red'>"+contentdata[i][6]+
									 "</span>");
								 }else if(contentdata[i][6]=="全部退货"){
									 $("#statucolor3").replaceWith("<a id='typestyle2"+contentdata[i][0]+"' name='a0021' href='#' style='text-decoration:underline;color:blue'  data-toggle='modal' data-target='#myModal3'>"+contentdata[i][6]+
									 "</a>");
								 }else if(contentdata[i][6]=="部分退货"){
									 $("#statucolor3").replaceWith("<a id='a2typestyle2"+contentdata[i][0]+"' name='a0022' href='#' style='text-decoration:underline;color:blue'  data-toggle='modal' data-target='#myModal3'>"+contentdata[i][6]+
									 "</a>");
								 }else{
									 $('#statucolor3').replaceWith("<span>"+contentdata[i][6]+
									 "</span>");
								 }
								
								
					 }
					 $("a[name=a0021]").click(function(){
							var id=this.id;
							var showid=id.slice(10);
							console.log(showid);
							$.getJSON("entry/findPoreturnsbyPoid",{findpoid:showid},function(json){
								console.log(json);
								$("#tbodyprobtn3").empty();
								for(var j=0;j<json.length;j++){
									 function p(s){
										 if(s<10){
											  s='0'+s;
										  }else{
											  s=s
										  }
										 return s;
									 }
									  
									 var d=new Date(json[j][3]);
									 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
									$("#tbodyprobtn3").append(
											 "<tr>"
											 +"</td>"
											 +"<td>"+json[j][0]
											 +"</td>"
											 +"<td>"+datetime
											 +"</td>"
											 +"<td>"+json[j][4]
											 +"</td>"
											 +"<td>"+json[j][2]
											 +"</td>"
											 +"</tr>"
									);
								}
								
							});
						});
					 $("a[name=a0022]").click(function(){
						 var id=this.id;
						 var showid=id.slice(12);
						 console.log(showid);
						 $.getJSON("entry/findPoreturnsbyPoid",{findpoid:showid},function(json){
							 console.log(json);
							 $("#tbodyprobtn3").empty();
							 for(var j=0;j<json.length;j++){
								 function p(s){
									 if(s<10){
										 s='0'+s;
									 }else{
										 s=s
									 }
									 return s;
								 }
								 
								 var d=new Date(json[j][3]);
								 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
								 $("#tbodyprobtn3").append(
										 "<tr>"
										 +"</td>"
										 +"<td>"+json[j][0]
										 +"</td>"
										 +"<td>"+datetime
										 +"</td>"
										 +"<td>"+json[j][4]
										 +"</td>"
										 +"<td>"+json[j][2]
										 +"</td>"
										 +"</tr>"
								 );
							 }
							 
						 });
					 });
				 $("td[name=tdid3]").show(function(){
						var id=this.id;
						var numb=id.slice(5);
						console.log(numb);
						var status=$("#input3"+numb).val();
						console.log(status);
						if(status=="未入库"){
							 $("#btn13"+numb).show();
						 }else{
							 $("#btn13"+numb).hide();
						 }
					 });
				 $("button[name=btn0013]").click(function(){
					 var id=this.id;
					 var numb=id.slice(5);
					 $("#poid").val(numb);
				 });

					//---分页开始---//
						 var totalpagenumber=json.totalPages;
						 $(".pagination").empty();
						 $(".pagination").append('<li class=""><a class="page-link" href="#" id="firstpage3">首页</a></li>');
						 $(".pagination").append('<li class=""><a class="page-link" href="#" id="updata3">上一页</a></li>');
						 for(var j=0;j<totalpagenumber;j++){
							 $(".pagination").append('<li class="page-item" id="pageno'+j+'"><a class="page-link" href="#">'+(j+1)+'</a></li>');
						 }
						
						 $(".pagination").append('<li class=""><a class="page-link" href="#" id="nextdate3">下一页</a></li>');
						 //首页
						 $("#firstpage3").click(function(){
							 startpage3=0;
							 getDataby30day();
						 });
						 //上一页
						 $("#updata3").click(function(event){
							 if(json.first){
								 event.preventDefault();
							 }else{
								 var intnum=new Number(startpage3);
								 startpage3=startpage3-1;
								 getDataby30day();
							 }
						 });
						 //下一页
						 $("#nextdate3").click(function(event){
							 if(json.last){
								 event.preventDefault();
							 }else{
								 var intnum=new Number(startpage3);
								 startpage3=startpage3+1;
								 getDataby30day();
							 }
						 });
						 //当前页面
						 $(".page-item").click(function(){
							 var id=this.id;
							var intnum=id.substr(6);
							startpage3=intnum;
							getDataby30day();
						 });
						 $(".page-item").removeClass("active");
						 $("#pageno"+startpage3).addClass("active");
					 //--分页结束--//
				 	});
				 }
			 });
			 $("#selectbtn").click(function(){
				 var starttime=$("#selectstarttime").val();
				 var lasttime=$("#selectlasttime").val();
				 $("#excelbtnstarttime").val(starttime);
				 $("#excelbtnlasttime").val(lasttime);
				 if(starttime>lasttime){
					 alert("开始时间不能晚于结束时间");
				 }else{
					 var startpage4=0;
					 getDatabytime();
					 function getDatabytime(){
						 $("#chooseth").hide();
						 $.getJSON("entry/showPolistBytime",{selectstarttime:starttime,selectlasttime:lasttime,start:startpage4},function(json){
							 console.log(json);
							 var contentdata=json.content;
							 $("#tbodyprobtn").empty();
							 for(var i=0;i<contentdata.length;i++){
								 function p(s){
									 if(s<10){
										  s='0'+s;
									  }else{
										  s=s
									  }
									 return s;
								 }
								  
								 var d=new Date(contentdata[i][3]);
								 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
										 $("#tbodyprobtn").append(
												 "<tr>"
												 +"<td>"+contentdata[i][0]
												 +"</td>"
												 +"<td>"+contentdata[i][1]
												 +"</td>"
												 +"<td>"+contentdata[i][2]
												 +"</td>"
												 +"<td>"+contentdata[i][4]
												 +"</td>"
												 +"<td>"+datetime
												 +"</td>"
												 +"<td>"+contentdata[i][7]
												 +"</td>"
												 +"<td name='tdid4' id='tdid4"+contentdata[i][0]+"'><span id='statucolor4'>"+contentdata[i][6]
												 +"</span></td>"
												 +"<td><button  type='button' class='btn btn-outline-info btn-sm' data-toggle='modal' data-target='#myModal2'id='btn14"+contentdata[i][0]+"' name='btn0014' >退货</button>"
												 +"<input type='hidden' class='form-control' id='input4"+contentdata[i][0]+"' name='inputname4'/>"
												 +"</td>"
												 +"</tr>"
										 ) 
										 $("#input4"+contentdata[i][0]).val(contentdata[i][6]);
										 if(contentdata[i][6]=="未入库"){
											 $('#statucolor4').replaceWith("<span style='color:red'>"+contentdata[i][6]+
											 "</span>");
											
										 }else if(contentdata[i][6]=="全部退货"){
											 $("#statucolor4").replaceWith("<a id='typestyle3"+contentdata[i][0]+"' name='a0031' href='#' style='text-decoration:underline;color:blue'  data-toggle='modal' data-target='#myModal3'>"+contentdata[i][6]+
											 "</a>");
										 }else if(contentdata[i][6]=="部分退货"){
											 $("#statucolor4").replaceWith("<a id='a2typestyle3"+contentdata[i][0]+"' name='a0032' href='#' style='text-decoration:underline;color:blue'  data-toggle='modal' data-target='#myModal3'>"+contentdata[i][6]+
											 "</a>");
										 }else{
											 $('#statucolor4').replaceWith("<span>"+contentdata[i][6]+
											 "</span>");
										 }
										
										
							 }
							 $("a[name=a0031]").click(function(){
									var id=this.id;
									var showid=id.slice(10);
									console.log(showid);
									$.getJSON("entry/findPoreturnsbyPoid",{findpoid:showid},function(json){
										console.log(json);
										$("#tbodyprobtn3").empty();
										for(var j=0;j<json.length;j++){
											 function p(s){
												 if(s<10){
													  s='0'+s;
												  }else{
													  s=s
												  }
												 return s;
											 }
											  
											 var d=new Date(json[j][3]);
											 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
											$("#tbodyprobtn3").append(
													 "<tr>"
													 +"</td>"
													 +"<td>"+json[j][0]
													 +"</td>"
													 +"<td>"+datetime
													 +"</td>"
													 +"<td>"+json[j][4]
													 +"</td>"
													 +"<td>"+json[j][2]
													 +"</td>"
													 +"</tr>"
											);
										}
										
									});
								});
							 $("a[name=a0032]").click(function(){
								 var id=this.id;
								 var showid=id.slice(12);
								 console.log(showid);
								 $.getJSON("entry/findPoreturnsbyPoid",{findpoid:showid},function(json){
									 console.log(json);
									 $("#tbodyprobtn3").empty();
									 for(var j=0;j<json.length;j++){
										 function p(s){
											 if(s<10){
												 s='0'+s;
											 }else{
												 s=s
											 }
											 return s;
										 }
										 
										 var d=new Date(json[j][3]);
										 var datetime=d.getFullYear() + '-' + p((d.getMonth() + 1)) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds()); 
										 $("#tbodyprobtn3").append(
												 "<tr>"
												 +"</td>"
												 +"<td>"+json[j][0]
												 +"</td>"
												 +"<td>"+datetime
												 +"</td>"
												 +"<td>"+json[j][4]
												 +"</td>"
												 +"<td>"+json[j][2]
												 +"</td>"
												 +"</tr>"
										 );
									 }
									 
								 });
							 });
						 $("td[name=tdid4]").show(function(){
								var id=this.id;
								var numb=id.slice(5);
								console.log(numb);
								var status=$("#input4"+numb).val();
								console.log(status);
								if(status=="未入库"){
									 $("#btn14"+numb).show();
								 }else{
									 $("#btn14"+numb).hide();
								 }
							 });
						 $("button[name=btn0014]").click(function(){
							 var id=this.id;
							 var numb=id.slice(5);
							 $("#poid").val(numb);
						 });

							//---分页开始---//
								 var totalpagenumber=json.totalPages;
								 $(".pagination").empty();
								 $(".pagination").append('<li class=""><a class="page-link" href="#" id="firstpage4">首页</a></li>');
								 $(".pagination").append('<li class=""><a class="page-link" href="#" id="updata4">上一页</a></li>');
								 for(var j=0;j<totalpagenumber;j++){
									 $(".pagination").append('<li class="page-item" id="pageno'+j+'"><a class="page-link" href="#">'+(j+1)+'</a></li>');
								 }
								
								 $(".pagination").append('<li class=""><a class="page-link" href="#" id="nextdate4">下一页</a></li>');
								 //首页
								 $("#firstpage4").click(function(){
									 startpage4=0;
									 getDatabytime();
								 });
								 //上一页
								 $("#updata4").click(function(event){
									 if(json.first){
										 event.preventDefault();
									 }else{
										 var intnum=new Number(startpage4);
										 startpage4=startpage4-1;
										 getDatabytime();
									 }
								 });
								 //下一页
								 $("#nextdate4").click(function(event){
									 if(json.last){
										 event.preventDefault();
									 }else{
										 var intnum=new Number(startpage4);
										 startpage4=startpage4+1;
										 getDatabytime();
									 }
								 });
								 //当前页面
								 $(".page-item").click(function(){
									 var id=this.id;
									var intnum=id.substr(6);
									startpage4=intnum;
									getDatabytime();
								 });
								 $(".page-item").removeClass("active");
								 $("#pageno"+startpage4).addClass("active");
							 //--分页结束--//
					 		});
					 	}
				 	
				 }
			 });
	 //--查询结束--//
	 //--取消查询--//
	 $("#selectbtn2").click(function(){
			var startpage=0;
			 $("#selectname").val("");
			getData();
		});
	 //--取消查询--//
	
});
